package fr.babos.test.components 
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.system.Capabilities;
	import flash.text.TextField;
	import fr.babos.core.masters.MasterSprite;
	import fr.babos.graphic.components.base.BorderContainer;
	import fr.babos.graphic.components.base.ResizableComponent;
	import fr.babos.graphic.components.base.StageWrapper;
	import fr.babos.utils.EnvUtils;
	import fr.babos.utils.MathUtils;

	
	/**
	 * @author ZoulouX
	 */
	public class StageWrapperTest extends Sprite
	{
		private var _wrapper:StageWrapper;
		private var _textField:TextField;
		
		public function StageWrapperTest ()
		{
			if (stage != null)
				init()
			else
				addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		protected function init (event:Event = null):void
		{
			_wrapper = new StageWrapper(stage);
			
			_textField = new TextField();
			
			_textField.width = 300;
			_textField.height = 300;
			
			addChild(_textField);
			
			_wrapper.onResized.add(function ():void {
				_textField.text = "";
				_textField.appendText("Screen size : " + MathUtils.fixed(EnvUtils.getScreenSize()) + "\"\n")
				_textField.appendText("Screen DPI : " + Capabilities.screenDPI + "\n")
				_textField.appendText("Screen definition : " + Capabilities.screenResolutionX + "px, " + Capabilities.screenResolutionY + "px\n")
				_textField.appendText("Wrapper scaleX : " + _wrapper.scaleX + "\n")
				_textField.appendText("Wrapper scaleY : " + _wrapper.scaleY + "\n")
				_textField.appendText("Wrapper width : " + _wrapper.width + " px\n");
				_textField.appendText("Wrapper height : " + _wrapper.height + " px\n");
			});
			_wrapper.onResized.dispatch();
			
			new BorderContainer(0xFF0000, 3).center(0, 0).size(100, 100).into(_wrapper);
			new BorderContainer(0xFF0000, 3).place(1, 1, 1, 1).into(_wrapper);
		}
	}
}